from functools import wraps
from django.shortcuts import render, redirect


def auth(func):
    @wraps(func)
    def inner(request, *args, **kwargs):
        userobj = request.session.get("name")
        if not userobj:
            return redirect('/')
        res = func(request, *args, **kwargs)
        return res

    return inner
